//
// Created by Administrator on 2023/11/14.
//
#include "iostream"

using namespace std;
const int N = 1e5 + 10;
int A[N], B[N];
int n, m;

int main() {
    cin >> n >> m;

    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> B[i];
    }

    for (int i = 0, j = 0; j < m; j++) {
        while (A[i] == B[j])i++;
        if (i == n) {
            cout << "YES";
            return 0;
        }
    }
    cout << "No";
}